import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import "dayjs/locale/zh-cn";
dayjs.locale("zh-cn");
dayjs.extend(relativeTime);

export function getRelativeTime(time: number) {
  const now: any = dayjs();
  const date: any = dayjs(time);
  if (date.isSame(now, "day")) return "今日";
  if (date.isSame(now.subtract(1, "day"), "day")) return "昨日";
  if (date.isSame(now, "year")) return date.format("M月D日");
  return date.format("YYYY年M月D日");
}
